module Wondercap
  module Syscmd

    def syscmd(command, output_io = nil, no_log = false)
      logger.info(command)
      
      command_output = %x(#{command})
      output_io.write(command_output) if output_io
      
      logger.debug(command_output) unless no_log
      $?.exitstatus
    end
    
    def syscmd_output(command, no_log = false)
      logger.info(command)

      command_output = %x(#{command})
      logger.debug(command_output) unless no_log
      
      raise RuntimeError.new("command failed: #{command}") if $?.exitstatus != 0
      command_output
    end    
    
  end
end